//
//  VC7Proximity.swift
//  ChapterAll
//
//  Created by Kevin on 2020/4/28.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class VC7Proximity: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // 开启获取设备距离感应器的数据
        UIDevice.current.isProximityMonitoringEnabled = true
        NotificationCenter.default.addObserver(self, selector: #selector(notiProximity(noti:)), name: UIDevice.proximityStateDidChangeNotification, object: nil)
    }
    
    @objc func notiProximity(noti:Notification) -> Void {
        if UIDevice.current.proximityState {
            print("近")
        }else {
            print("远")
        }
    }
}
